/**
 * Created by loso on 2017/3/16.
 */
public class _9_PalindromeNumber {

    public static void main(String[] args) {
        _9_PalindromeNumber a = new _9_PalindromeNumber();
        System.out.println(a.isPalindrome(1000000001));
    }
    public boolean isPalindrome(int x) {
        if (x<0){
            return false;
        }

        long maxbit = 1;
        while(maxbit <= x){
            maxbit = maxbit * 10;
        }
        maxbit = maxbit/10;
        long minbit = 1;
        while(maxbit > minbit){
            long mbigbit = x%(maxbit*10)/maxbit;
            long msbit = x%(minbit*10)/minbit;
            if (mbigbit != msbit){
                return false;
            }
            maxbit = maxbit/10;
            minbit = minbit*10;
        }
        return true;
    }

    public boolean isPalindromebigboss(int x) {
        if (x<0 || (x!=0 && x%10==0)) return false;
        int rev = 0;
        while (x>rev){
            rev = rev*10 + x%10;
            x = x/10;
        }
        return (x==rev || x==rev/10);
    }

}
